var navidiv = '', notice_float = '';

document.write('<a id="moredown_click" class="Admin_moredown" href="javascript:void(0)">切换系统<span class="more"></span></a>');

navidiv += '<div id="sysnavi" class="admin_layer_system admin_layer_system_01" style="display:none; position:absolute; top:33px; right:83px;overflow:hidden;  height:auto; z-index:9; ">';
navidiv += '<dl class="clearfix"><dt><a href="javascript:void(0);">title1</a></dt><dd><a href="javascript:void(0);">title2</a></dd><dd><a href="javascript:void(0);">title3</a></dd></dl>';
navidiv += '</div>';

notice_float += '<a href="javascript:void(0);" class="Adm_float_top" style=" right:10px; bottom:80px;position:fixed"></a>';
notice_float += '<div class="Adm_float_notice" style=" right:10px; bottom:50px;position:fixed"> <a href="javascript:void(0)" id="admin_show_notice" class="notice_icon"><span id="admin_notice_num" style="display:none" class="notice_num"><em>99</em></span></a>';
notice_float += '<div id="admin_show_notice_div" class="Adm_float_pannel Adm_notice_pannel" style="background-color:white">';
notice_float += '<div class="float_pannel_title">';
notice_float += '<p class="title_txt">消息提醒 - (<span id="admin_notice_num2">0</span>条未读消息)</p>';
notice_float += '<a href="javascript:void(0)" id="admin_notice_close" class="min_win_wrap"><span class="min_win">&nbsp;</span></a> </div>';
notice_float += '<div class="float_pannel_content clearfix">';
notice_float += '<ul id="admin_notice_intro" class="pannel_list">';
notice_float += '</ul>';
notice_float += '<p class="pannel_more"><a href="#">更多</a></p>';
notice_float += '</div>';
notice_float += '</div>';
notice_float += '</div>';
notice_float += '<div class="Adm_float_feedback" style=" right:10px; bottom:20px;position:fixed"> <a href="javascript:void(0)" id="admin_show_feedback" class="feedback_icon"></a>';
notice_float += '<div id="admin_show_feedback_div" class="Adm_float_pannel Adm_feedback_pannel" style="background-color:white">';
notice_float += '<div class="float_pannel_title">';
notice_float += '<p class="title_txt">问题反馈</p>';
notice_float += '<a href="javascript:void(0)" id="admin_feedback_close" class="min_win_wrap"><span class="min_win">&nbsp;</span></a> </div>';
notice_float += '<div class="float_pannel_content clearfix">';
notice_float += '<div style="height:290px">';
notice_float += '<iframe id="admin_feedback_iframe" frameborder=0 width=100% height=100% scrolling=no src=""></frame>';
notice_float += '</div>';
notice_float += '</div>';
notice_float += '</div>';
notice_float += '</div>';

$(window.top.document).find("body:last").append(navidiv);
$(window.top.document).find("body:last").append(notice_float);

$(".Adm_float_top").click(function(){
    $("html, body").animate({scrollTop:0}, 300);
});

var admin_feedback_url = 'welcome.html?url=';
$(function() {
    //显示隐藏消息提示页面
    $("#admin_show_notice").click(function(){
        if ($("#admin_show_notice_div").is(":hidden")){
            $("#admin_show_notice_div").show();
            //如果意见反馈为开启状态 模拟点击一次按钮
            if($("#admin_show_feedback_div").is(":visible")) {
                $("#admin_show_feedback").click();
            }
        }else{
            $("#admin_show_notice_div").hide();
        }
    });
    //关闭消息按钮
    $("#admin_notice_close").click(function() {
        $("#admin_show_notice").click();
    });
    //显示隐藏消息反馈页面
    $("#admin_show_feedback").click(function(){
        if ($("#admin_show_feedback_div").is(":hidden")){
            $("#admin_show_feedback_div").show();
            //如果消息提示页面为显示 模拟点击一次按钮
            if($("#admin_show_notice_div").is(":visible")) {
                $("#admin_show_notice").click();
            }
            if($("#admin_feedback_iframe").attr("src")) {
                $("#admin_feedback_iframe").attr("src", admin_feedback_url + window.location);
            }
        }else{
            $("#admin_show_feedback_div").hide();
        }
    });
    //关闭留言反馈按钮
    $("#admin_feedback_close").click(function() {
        $("#admin_show_feedback").click();
    });
    //切换系统
    $("#moredown_click").click(function(){
        if ($("#sysnavi").is(":hidden")){
            $("#sysnavi").show();
            $("#moredown_click").parent().addClass("current");
        }else{
            $("#sysnavi").hide();
            $("#moredown_click").parent().removeClass("current");
        }
    });
});

var notice_url = 'aj_mynotice.php?callback=?';
var notice_look_url = 'notice_look_url.php';
var st_notice = null;
$(function(){
    ajax_get_notice();
});
function ajax_get_notice() {
    return; // 暂时没用
    if(st_notice) {
        clearTimeout(st_notice);
        st_notice = null;
    }
    $.ajax({
       type: "GET",
       url: notice_url,
       cache: false,
       dataType:"jsonp",
       success: function(json){
          if(json.errno == 1 ) {
             var total = json.notice_total;
             $("#admin_notice_num2").html(total);
             $("#admin_notice_intro").html("");
             if(total<=0) {
                 $("#admin_notice_num").hide();
                 if(json.is_online) {
                     st_notice = setTimeout("ajax_get_notice()",60000);
                 }
                 return;
             }
             var notice_intro = json.notice_intro;
             var admin_notice_intro = '';
             for (var ak in notice_intro) {
                admin_notice_intro += '<li class="list_li">'+notice_intro[ak].from_staff+':<a href="'+notice_look_url+'">'+notice_intro[ak].total+'条未读</a></li>';
             }
             $("#admin_notice_intro").html(admin_notice_intro);
             if(total>99) total = 'N';
             $("#admin_notice_num").html('<em>'+total+'</em>');
             $("#admin_notice_num").show();
             //如果当前环境为开发环境，则不请求线上接口
             if(json.is_online) {
                 st_notice = setTimeout("ajax_get_notice()",60000);
             }
          }
       }
    });
}
